
import 'package:valovault_reminder/common/config/val_assets_name.dart';
import 'package:valovault_reminder/pages/base/val_app_common_bar.dart';
import 'package:valovault_reminder/pages/base/val_base_ui_page.dart';
import 'package:valovault_reminder/pages/home/models/val_post_record_model.dart';
import 'package:flutter/material.dart';

class ValNoticeInfoPage extends StatefulWidget {
  final ValPostRecordModel listModel;

  const ValNoticeInfoPage({super.key, required this.listModel});

  @override
  State<ValNoticeInfoPage> createState() => _ValNoticeInfoPageState();
}

class _ValNoticeInfoPageState extends ValBaseUIPageState<ValNoticeInfoPage> {

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    isAppBar = true;
    extendBodyBehindAppBar = true;
  }

  @override
  PreferredSizeWidget? get appBar {
    return ValAppCommonBar(
      backgroundColor: Colors.transparent,
      title: 'Details',
      titleColor: Colors.white,
      brightness: Brightness.dark,
      leadingWidget: GestureDetector(
          onTap: () {
            Navigator.of(context).pop();
          },
          child: Image.asset(
            '${ValAssetsName.ASSETS_HOME}val_common_nav_back.png',
            width: 30,
            height: 30,
          )
      ),
    );
  }

  Widget createTextContentElement(String content) {
    return  Container(
      height: 49,
      margin: const EdgeInsets.only(left: 24, right: 24, bottom: 10),
      padding: const EdgeInsets.only(left: 20, right: 20),
      alignment: Alignment.centerLeft,
      decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20),
          border: Border.all(width: 1, style: BorderStyle.solid, color: const Color(0xFFE8A229)
        ),
      ),
      child: Text(content,
        style: const TextStyle(color: Colors.white, fontSize: 20, fontWeight: FontWeight.w500), overflow: TextOverflow.clip,),
    );
  }

  @override
  Widget buildBody(BuildContext context) {
    return Stack(
      children: [
        // 背景图
        Positioned(
            top: 0, left: 0, right: 0, bottom: 0,
            child: Container(
                decoration: const BoxDecoration(
                  color: Color(0xFF080822),
                  image: DecorationImage(
                        image: AssetImage('${ValAssetsName.ASSETS_Message}val_notice_info_ground.png'), fit: BoxFit.fill),
                ),
            ),
        ),
        // 文本
        Positioned(
          bottom: MediaQuery.of(context).padding.bottom + 25, left: 0, right: 0, height: 264,
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              createTextContentElement('Name: ${widget.listModel.title}'),
              createTextContentElement('Amount: ${widget.listModel.followed}\$'),
              createTextContentElement('Due Date: ${widget.listModel.publishDate}'),
              Container(
                height: 49,
                margin: const EdgeInsets.only(top: 10, left: 24, right: 24, bottom: 10),
                padding: const EdgeInsets.only(left: 20, right: 20),
                alignment: Alignment.centerLeft,
                decoration: BoxDecoration(
                  borderRadius: BorderRadius.circular(20),
                  gradient: const LinearGradient(
                    begin: Alignment.centerLeft,
                    end: Alignment.centerRight,
                    colors: [
                      Color(0xFFE8A229),
                      Color(0xFFF9C03D),
                      Color(0xFFFCCC41),
                    ],
                  ),
                ),
                child: Text('Reminder Time: ${widget.listModel.image}',
                  style: const TextStyle(color: Color(0xFF333333), fontSize: 20, fontWeight: FontWeight.w500), overflow: TextOverflow.clip,),
              ),
            ],
          ),
        ),
      ],
    );
  }
}
